<template>
  <!-- 我的抄送 -->
  <el-container>
    <!-- <el-header>
      <div class="left-panel">
        <el-button
          type="primary"
          icon="el-icon-plus"
          @click="add"
          v-auth-button="['add/reimburseManagement']"
        ></el-button>
      </div>
      <div class="right-panel">
        <div class="right-panel-search">
          <el-input
            v-model="searchValue.search"
            placeholder="名称"
            clearable
          ></el-input>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="upsearch"
          ></el-button>
        </div>
      </div>
    </el-header> -->
    <el-main class="nopadding">
      <scTable
        ref="table"
        :apiObj="apiObj"
        row-key="id"
        stripe
        @filterType="filterType"
        @row-dblclick="handleRowClick"
      >
        <el-table-column label="ID" prop="id" width="80"></el-table-column>
        <el-table-column
          label="主题"
          prop="title"
          min-width="150"
        ></el-table-column>

        <el-table-column label="摘要" prop="detail" min-width="200">
          <template #default="scope">
            <item-detail
              ref="itemDetail"
              :data="scope.row.detail"
            ></item-detail>
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="totalStatus" width="300">
          <template #default="scope">
            <!-- 0未审核 1审核通过 2审核拒绝  -->
            <el-tag type="warning" v-if="scope.row.totalStatus == 0">
              待审核
            </el-tag>
            <el-tag type="success" v-if="scope.row.totalStatus == 1">
              通 过
            </el-tag>
            <el-tag type="danger" v-if="scope.row.totalStatus == 2">
              未通过
            </el-tag>
            <el-tag type="warning" v-if="scope.row.totalStatus == 3">
              审核中
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="申请时间"
          prop="createTime"
          width="300"
        ></el-table-column>
        <el-table-column
          label="申请人"
          prop="applyName"
          width="300"
        ></el-table-column>
      </scTable>
    </el-main>
  </el-container>
</template>
<script>
import itemDetail from '../components/itemDetail.vue'
import { queryTypeByDic } from '@/utils/getData'
import { handleClick, initTableRow } from '@/utils/handleRouter'
export default {
  name: 'mySend',
  data () {
    return {
      apiObj: this.$API.home.getMySendList,
      produceStatus: [],//生产单状态
      deliverStatus: [],//送货状态
      followType: [],//跟进类型
      searchValue: {
        search: null
      }
    }
  },
  components: {
    itemDetail
  },
  mounted () {
    this.getType()
  },
  methods: {
    async getType () {
      this.produceStatus = await queryTypeByDic('produceStatus')
      this.deliverStatus = await queryTypeByDic('deliverStatus')
      this.followType = await queryTypeByDic('followType')
    },
    filterType (data) {
      initTableRow(data)
      // streamType 1报价 2合同 3生产 4送货 5回款 6回款计划 7跟踪记录 8报销 9借款 10客户 11日程
      // let tableData = data
      // tableData.forEach(item => {
      //   item.applyName = item.detail.applicantName
      //   item.status = item.detail.status
      //   item.detail.streamType = item.streamType
      //   switch (item.streamType) {
      //     case 1:
      //       item.title = item.detail.quotesName
      //       item.detail.streamTypeName = '报价'
      //       break
      //     case 2:
      //       item.title = item.detail.name
      //       item.detail.streamTypeName = '合同'
      //       break
      //     case 3:
      //       item.title = item.detail.name
      //       item.detail.streamTypeName = '生产'
      //       this.produceStatus.forEach(p_item => {
      //         if (p_item.value == item.detail.type) {
      //           item.detail.typeName = p_item.name
      //         }
      //       })
      //       break
      //     case 4:
      //       item.title = item.detail.name
      //       item.detail.streamTypeName = '送货'
      //       this.deliverStatus.forEach(p_item => {
      //         if (p_item.value == item.detail.type) {
      //           item.detail.typeName = p_item.name
      //         }
      //       })
      //       break
      //     case 5:
      //       item.title = item.detail.paymentName
      //       item.detail.streamTypeName = '回款'
      //       break
      //     case 7:
      //       item.title = item.detail.followName
      //       item.detail.streamTypeName = '跟踪记录'
      //       this.followType.forEach(p_item => {
      //         if (p_item.value == item.detail.type) {
      //           item.detail.typeName = p_item.name
      //         }
      //       })
      //       break
      //     case 8:
      //       item.title = item.detail.reimbursementName
      //       item.detail.streamTypeName = '报销'
      //       break
      //     case 9:
      //       item.title = item.detail.loanName
      //       item.detail.streamTypeName = '借款'
      //       break
      //     case 10:
      //       item.title = item.detail.customerName
      //       item.detail.streamTypeName = '客户'
      //       break
      //   }
      // })

    },
    handleRowClick (row) {
      handleClick(row.streamType, row.detail.id)
    },

  }
}
</script>

<style>
</style>